/**      
 * @file		newPointers.cpp
 * @description		This demonstrates use of the new operator
 *			and pointers. The new operator allocates memory
 *			for a variable of a specified type.
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		1.0
 */
#include <iostream>
using namespace std;

/**
 * @return zero if the application executes successfully
 */
int main() {
	
	int *p1;
	int *p2;

	// allocate memory for an integer variable
	p1 = new int;
	// assign the variable a value
	*p1 = 22;

	// set p2 to point to the memory of p1
	p2 = p1;
	// output the value that the pointers point to
	cout << "*p1 == " << *p1 << endl;
	cout << "*p2 == " << *p2 << endl;

	*p2 = 83;
	// output the value that the pointers point to
	cout << "*p1 == " << *p1 << endl;
	cout << "*p2 == " << *p2 << endl;

	// set p1 to point to a new memory location
	p1 = new int;
	// set the value in that new memory location
	*p1 = 98;
	cout << "*p1 == " << *p1 << endl;
	cout << "*p2 == " << *p2 << endl;

	return 0;
}
